/**
 * @file   1117.cpp
 * @author Shuang Hu <hsmath@ubuntu>
 * @date   Tue Jun  1 18:16:23 2021
 * 
 * @brief  PAT advanced,1117
 * 
 * 
 */
#include<iostream>
#include<vector>
#include<map>
using namespace std;
int main(){
    int N;
    cin>>N;
    map<int,int> miletotimes;
    for(int i=0;i<N;i++){
	int d;
	cin>>d;
	miletotimes[d]++;
    }
    int j=1;
    while(1){
	N=N-miletotimes[j];
        if(j>N){
	    break;
	}
	j++;
    }
    j--;
    cout<<j<<endl;
}
